//
//  YXMachinesViewModel.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/29.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXMachinesViewModel.h"
#import "YXMachinesModel.h"
@implementation YXMachinesViewModel

+(void)getQueryGoodslistById:(NSString *)sessionId ModelList:(void(^)(NSArray *array))mdList Failure:(void(^)(NSError *error))failure {
//    http://121.196.210.134:8082/mpos/wx/goods_list.do?sessionId=b06bb145-32bd-4dea-9463-45b4b76c9f3e
    NSString *urlStr = @"goods_list.do";
    NSDictionary *parameter = @{@"sessionId":sessionId};
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:parameter success:^(id responseObject) {
//        NSLog(@"请求成功%@",responseObject);
        if (REQUESTDATASUCCESS) {
            NSArray *listArr = responseObject[@"body"][@"list"];
            if (mdList) {
                mdList(listArr);
            }
        }
    } failure:^(NSError *error) {
        NSLog(@"请求失败%@",error);
        if (failure) {
            failure(error);
        }
    }];
    
    
}

+(void)getQueryAddOrderById:(NSString *)sessionId Goods:(NSString *)goods TotalPrice:(NSString *)totalPrice OrdersTypes:(NSString *)ordersTypes ModelList:(void(^)(NSArray *array))mdList Failure:(void(^)(NSError *error))failure {
    
//http://121.196.210.134:8082/mpos/wx/addOrder.do?sessionId=137c9a34-d907-47f1-8e9a-56a8457a741f&totalPrice=99&ordersTypes=0&goods=[{goodsId
//
//    :"MJFNOE21I6XQ5OEGE67JPKIVRXAMWTTE",num:"1"}]

    NSString *urlStr = @"addOrder.do";
    NSDictionary *parameter = @{@"sessionId":sessionId,@"goods":goods,@"totalPrice":totalPrice,@"ordersTypes":ordersTypes};
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:parameter success:^(id responseObject) {
        NSLog(@"请求成功%@",responseObject);
        if (REQUESTDATASUCCESS) {
            NSArray *arr;
            if (mdList) {
                mdList(arr);
            }
        }
    } failure:^(NSError *error) {
        NSLog(@"请求失败%@",error);
        if (failure) {
            failure(error);
        }
    }];
}


@end
